<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        #demo {
            width: 300px;
            border: 1px solid red;
            padding: 10px;
            margin:15px auto;
        }
    </style>
</head>
<body>
<div id="demo">
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
    asdfasdfasdasdfasdfasdfasdfasdf
</div>
</body>
</html>
<script>
    var demo = document.getElementById("demo");
    console.log(demo.style.width);  // style.width  只能得到行内式
    console.log(demo.offsetWidth);
    console.log(demo.offsetHeight);
</script>